#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2020/11/1 23:30
# @Author  : LJ
# @Site    : 
# @File    : 第三周_第二节.py
# @Software: PyCharm

classes = [
    {"name": "abyss", "age": 25, "grade": "A"},
    {"name": "kin", "age": 23, "grade": "B"},
    {"name": "tian", "age": 24, "grade": "B"},
    {"name": "hun", "age": 26, "grade": "A"},
    {"name": "exe", "age": 21, "grade": "A"}
]
def my_sort(i):
    return i["age"]

# 通过 age 升序排序

print(sorted(classes,key=lambda i: i['age']))
print(sorted(classes,key=my_sort))

def add_age(i):
    for i in range(len(classes)):
        return classes[i]["age"] + 1
# map 函数age+1
def age_add(i):
    i["age"] += 1
    return i
print(list(map(age_add,classes)))
# 过滤
def filter_grade(i):
    return i['grade'] != "A"

print(list(filter(filter_grade,classes)))
print(list(filter(lambda i:i["grade"] != "A",classes)))


#递归
def fei_bo(n):
    if n <= 1:
        return n
    else:
        return (fei_bo(n-1) + fei_bo(n-2))


for i in range(10):
    print(fei_bo(i))

print(fei_bo(10))